<form>
  <fiedset>
    <label for="username"><input name="username" type="text"/></label>
    <label for="password"><input name="password" type="password"/></label>
    <button type="submit" id="ok">OK</button>
    <button type="submit" id="cancel">Cancel</button>
  </fiedset>
  <script>
    console.log(window.opener);
    window.onload = function() {
      var ok = document.getElementById('ok');
      var cancel  = document.getElementById('cancel');
      ok.addEventListener('click', function() {
        window.returnValue = [document.username, document.password];
        window.close();
      }, false);
      cancel.addEventListener('click', function() {
        window.close();
      }, false);
    };
  </script>
</form>